# Copyright (c) 2024-present AI-Labs

import typer

from configs import config

shell_app = typer.Typer()

@shell_app.command()
def auto():
    """
    根据配置文件，自动识别启动哪些微服务
    """
    if config.opea_service.asr.enable == True:
        asr()
    if config.opea_service.tts.enable == True:
        tts()
    if config.opea_service.text2image.enable == True:
        text2image()
    if config.opea_service.image2image.enable == True:
        image2image()
    if config.opea_service.inpainting.enable == True:
        inpainting()
    if config.opea_service.vlm.enable == True:
        vlm()
    if config.opea_service.tryon.enable == True:
        tryon()

    """
    根据配置文件，自动识别启动哪些网关服务
    """
    if config.opea_gateway.chatservice.enable == True:
        chatservice()
    if config.opea_gateway.text2imageservice.enable == True:
        text2imageservice()
    if config.opea_gateway.image2imageservice.enable == True:
        image2imageservice()
    if config.opea_gateway.inpaintingservice.enable == True:
        inpaintingservice()
    if config.opea_gateway.audiochatservice.enable == True:
        audiochatservice()

@shell_app.command()
def asr():
    """
    启动自动语音识别服务
    """
    from modules.services.asr import start
    start()

@shell_app.command()
def tts():
    """
    启动文本转语音服务
    """
    from modules.services.tts import start
    start()

@shell_app.command()
def text2image():
    """
    启动文生图片服务
    """
    from modules.services.text2image import start
    start()

@shell_app.command()
def image2image():
    """
    启动图生图片服务
    """
    from modules.services.image2image import start
    start()

@shell_app.command()
def inpainting():
    """
    启动局部重绘服务
    """
    from modules.services.inpainting import start
    start()

@shell_app.command()
def vlm():
    """
    启动多模态理解服务
    """
    from modules.services.vlm import start
    start()

@shell_app.command()
def tryon():
    """
    启动虚拟试穿服务
    """
    from modules.services.tryon import start
    start()

@shell_app.command()
def chatservice():
    """
    启动大模型对话服务
    """
    from modules.gateways.chatservice import start
    start()

@shell_app.command()
def text2imageservice():
    """
    启动文生图像服务
    """
    from modules.gateways.text2imageservice import start
    start()

@shell_app.command()
def image2imageservice():
    """
    启动图生图像服务
    """
    from modules.gateways.image2imageservice import start
    start()

@shell_app.command()
def inpaintingservice():
    """
    启动局部重绘服务
    """
    from modules.gateways.inpaintingservice import start
    start()

@shell_app.command()
def audiochatservice():
    """
    启动语音对话服务
    """
    from modules.gateways.audiochatservice import start
    start()

if __name__ == '__main__':
    shell_app()
